package com.sunda.spmswms.mapper;

import com.sunda.spmswms.entity.SapBoxNoteDtl;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 箱码行项目表 Mapper 接口
 * </p>
 *
 * @author Wayne
 * @since 2021-03-29
 */
@Mapper
public interface SapBoxNoteDtlMapper extends BaseMapper<SapBoxNoteDtl> {

    @Update("UPDATE SAP_BOX_NOTE_DTL BND SET BND.DOMESTIC_QTY_RECEIVABLE = BND.QUANTITY, BND.DOMESTIC_QTY_RECEIVED = BND.QUANTITY\n" +
            "WHERE BND.BOX_NOTE = #{boxNote}")
    int updateSapBoxNoteDtl(@Param("boxNote") String boxNote, @Param("boxNoteQty") double boxNoteQty);

    @Select("SELECT COUNT(*) FROM SAP_BOX_NOTE_DTL WHERE BOX_NOTE= #{boxNote}")
    int validateBoxNote(@Param("boxNote") String boxNote);


    @Update("UPDATE SAP_BOX_NOTE_DTL BND SET BND.DOMESTIC_QTY_RECEIVED = #{domesticQtyReceived}, BND.REMARK = #{remark}\n" +
    "WHERE BND.BOX_NOTE=#{boxNote} AND BND.ITEM=#{item}")
    int updateSapBoxNoteDtlBeta(@Param("boxNote") String boxNote, @Param("item") int item, @Param("domesticQtyReceived") Double domesticQtyReceived, @Param("remark") String remarks);
}
